package org.atguigu.result;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author 海晨忆
 * @Des 数据封装
 * @Date 2025/8/6 18:20
 */
@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R OK() {
        return R.builder().code(200).msg("请求成功").data(null).build();
    }

    public static R OK(String msg) {
        return R.builder().code(200).msg(msg).data(null).build();
    }

    public static R OK(String msg, Object data) {
        return R.builder().code(200).msg(msg).data(data).build();
    }

    public static R OK(Object data) {
        return R.builder().code(200).msg("请求成功").data(data).build();
    }

    public static R FAIL() {
        return R.builder().code(500).msg("请求失败").data(null).build();
    }

    public static R FAIL(int code, String msg) {
        return R.builder().code(code).msg(msg).data(null).build();
    }


}
